package com.zyz.H_比较器.Comparator比较器;


import java.util.Arrays;

/**
 * @author: vick
 * @Date: 2025/3/19
 * @Description:
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        Person[] persons = {
                new Person("vick-A", 90),
                new Person("vick-H", 90),
                new Person("vick-B", 50),
                new Person("vick-C", 100),
        };

        //对数组进行排序
        Arrays.sort(persons, new PersonComparator());
        System.out.println(Arrays.toString(persons));

        System.out.println("=====");
        Person person1 = new Person("vick-C", 10);
        Person person2 = new Person("vick-d", 5);

        PersonComparator personComparator = new PersonComparator();
        int compare = personComparator.compare(person1, person2);
        if (compare == 0) {
            System.out.println("相等");
        }else if (compare < 0){
            System.out.println("person1 < person2");
        }else {
            System.out.println("person1 > person2");
        }

    }
}
